#include "comm.hpp"

int main()
{
    //以写的方式打开管道文件
    std::cout<<"client begin "<<std::endl;
    int wfd = open(NAMED_PIPE,O_WRONLY);
    std::cout<<"client end "<<std::endl;

    if(wfd < 0)
        exit(1);
    //write
    char buffer[1024];
    while(true)
    {
        std::cout << "Please Say# ";
        fgets(buffer,sizeof(buffer),stdin);//从输入流中获取内容
        if(strlen(buffer) > 0)
            buffer[strlen(buffer)-1] = 0;
        ssize_t n = write(wfd,&buffer,strlen(buffer));//把内容写入管道文件
        assert( n == strlen(buffer));
        (void)n;
    }

    close(wfd);
    return 0;
}